package guava;

import org.junit.Test;

import com.google.common.hash.BloomFilter;
import com.google.common.hash.Funnels;

public class BloomFiltersTest {
    @Test
    public void bloomFilterTest() {
        long star = System.currentTimeMillis();
        //误报率0.01
        BloomFilter<Integer> bloomFilters = BloomFilter.create(Funnels.integerFunnel(), 1000000, 0.01);
        for (int i = 0; i < 10000000; i++) {
            bloomFilters.put(i);
        }
        System.out.println(bloomFilters.mightContain(1));
        System.out.println(bloomFilters.mightContain(2));
        System.out.println(bloomFilters.mightContain(3));
        System.out.println(bloomFilters.mightContain(999999));
        System.out.println(bloomFilters.mightContain(400230340));
        long end = System.currentTimeMillis();
        System.out.println("执行时间：" + (end - star));
    }
}
